-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Link Navigation relative to current Environment #24483
Conversation
@@ -80,7 +80,7 @@ export default { | |||
}, | |||
CAPTURE_METRICS: lodashGet(Config, 'CAPTURE_METRICS', 'false') === 'true', | |||
ONYX_METRICS: lodashGet(Config, 'ONYX_METRICS', 'false') === 'true', | |||
DEV_PORT: process.env.PORT || 8080, | |||
DEV_PORT: process.env.PORT || 8082, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated since we now run dev on 8082 so fallback port should be 8082.
@@ -15,7 +14,12 @@ jest.doMock('react-native', () => { | |||
// runs against index.native.js source and so anything that is testing a component reliant on withWindowDimensions() | |||
// would be most commonly assumed to be on a mobile phone vs. a tablet or desktop style view. This behavior can be | |||
// overridden by explicitly setting the dimensions inside a test via Dimensions.set() | |||
let dimensions = CONST.TESTING.SCREEN_SIZE.SMALL; | |||
let dimensions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to make these changes because this mock file was importing CONST
file which was in turn importing src/libs/Url.js
file in which we have imported the polyfill. Since the polyfill import internally imports RN packages and since we are in test environment the packages were being used before mocking them (which is done later in this file) and the test suite broke.To fix this we have multiple options:
-
We can import the polyfill in the root
App.js
file as mentioned in the usage guidelines (https://github.com/charpeni/react-native-url-polyfill) but it will then overrideURL
andURLSearchParams
classes in the entire project.I actually committed that change in the previous commit and everything was working fine including the test cases.Also these 2 classes are not used much so the chance of breaking something is low and since the overrides basically extends the default RN classes so I think we are fine using this option too. -
Remove the import from the test suite before the mocking happens.In this option I had 2 further options:
- Remove the Url.js import from CONST.js as it was imported to use the addTrailingForwardSlash just at one place in the file.Also importing lib files in CONST file does not make sense.
- The other option was to remove the CONST file import in this file and that's what I have done now.
Let me know what you think is the best way forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the CONST file import in this file
Current solution you did works for me.
@francoisl what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah works for me too.
@@ -224,8 +9,8 @@ describe('Url', () => { | |||
it('It should work correctly with www in both urls', () => { | |||
expect(Url.hasSameExpensifyOrigin('https://www.new.expensify.com/inbox/124', 'https://www.new.expensify.com/action/123')).toBe(true); | |||
}); | |||
it('It should work correctly without https://', () => { | |||
expect(Url.hasSameExpensifyOrigin('new.expensify.com/action/1234', 'new.expensify.com/action/123')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this case was removed? It should still work without https://
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL href attributes always need to have a protocol in them otherwise it is an invalid URL.If you type google.com in any chat on STG and then hover over it to view the href it will show https://google.com, so our logic already creates the correct href
Any url without the protocol and // is treated as a relative URL and is not spec complaint.You can go to any browser and type new URL('google.com') in the console section and it will throw an error.
Therefore, the previous test case was invalid.
@@ -1,221 +1,6 @@ | |||
const Url = require('../../src/libs/Url'); | |||
|
|||
describe('Url', () => { | |||
describe('getURLObject()', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these example urls should still be unit tested in getPathFromURL
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests for getPathFromURL
@@ -15,7 +14,12 @@ jest.doMock('react-native', () => { | |||
// runs against index.native.js source and so anything that is testing a component reliant on withWindowDimensions() | |||
// would be most commonly assumed to be on a mobile phone vs. a tablet or desktop style view. This behavior can be | |||
// overridden by explicitly setting the dimensions inside a test via Dimensions.set() | |||
let dimensions = CONST.TESTING.SCREEN_SIZE.SMALL; | |||
let dimensions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the CONST file import in this file
Current solution you did works for me.
@francoisl what do you think?
@situchan @francoisl Any updates on PR review? |
@Talha345 please pull main. Unit Tests are now fixed in main |
Done! |
@situchan Bump for review! |
I am not able to get dev/staging |
@situchan How can i install multiple versions? You can simply set the environment by setting the ENV variable |
Reviewer Checklist
Screenshots/VideosWebweb-staging.movMobile Web - Chromemchrome-dev.movMobile Web - Safarimsafari-dev.movDesktopdesktop.movdesktop2.moviOSios-dev.movios-prod.movAndroidandroid-dev.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@francoisl all yours
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Hi @situchan @francoisl @Talha345 App/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js Lines 54 to 57 in a6fa52d
But the URL params is required to attachment URL. Steps to reproduce
You will see the copied URL:
is open wrong link without params
I think we need to exclude the attachment URLs from this condition or add new condition previous this condition to open the attachment URLs with full URL issue is reported in slack here by @ayazhussain79 |
Hi @ahmedGaber93, I see what you mean. We updated how the This can be resolved easily by updating
@situchan @francoisl Where should I update this change? Create a new PR or what? |
Yes, can you make a new PR please? |
bump @Talha345 |
🚀 Deployed to staging by https://github.com/francoisl in version: 1.3.56-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.56-24 🚀
|
Details
Fixed Issues
$ #22523
PROPOSAL: #22523 (comment)
Tests
Test Case 1:
Test Case 2:
In Dev: All 3 links should be external.
In STG: 2nd link should be internal
in PROD: Last link should be internal
This test case ensures that if an extra www subdomain is added to any URL, it is discarded and the correct behaviour prevails.
Note: In Dev ENV, you can change the line https://github.com/Expensify/App/compare/main...Talha345:fix/22523?expand=1#diff-810e7a5e5e8692ea5ea69e3b593e7e6abb3992e2682a7aaf89c8615db6840d83R22 and set it to
const environmentURL = CONST.STAGING_NEW_EXPENSIFY_URL;
orconst environmentURL = CONST.NEW_EXPENSIFY_URL;
to test the behaviour in STG and PROD environments on localhost.Offline tests
Same as above
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
web.mov
Mobile Web - Chrome
WhatsApp.Video.2023-08-12.at.2.57.19.PM.mp4
Mobile Web - Safari
safari.mov
Desktop
Since the desktop app runs on port 8083 so only localhost links with port 8083 will be treated as internal.
desktop.mov
iOS
Since the DEV_PORT returned in native apps is 8082, only localhost links with port 8082 will be treated as internal on IOS and Android.
ios.mov
Android
android.mov